-
Notifications
You must be signed in to change notification settings - Fork 65
starknet_committer,starknet_patricia: layout-dependent db-key separator #11641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2bf9147 to
56f611e
Compare
ArielElp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArielElp made 3 comments.
Reviewable status: 7 of 12 files reviewed, 3 unresolved discussions (waiting on @nimrod-starkware and @yoavGrs).
crates/starknet_committer/src/db/facts_db/types.rs line 56 at r3 (raw file):
Previously, yoavGrs wrote…
And maybe
fn create_facts_db_keyas well.
Done. (the constants, not separate function)
crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde.rs line 55 at r3 (raw file):
Previously, yoavGrs wrote…
Index layer wraps
StarknetStorageValueand ignores this method.Maybe the right thing was to define
pub struct FactLayoutStarknetStorageValue(pub StarknetStorageValue);If you agree, please add TODO for it.
I don't follow, we want this method ignored, we have a separate DBObject implementation.
Unrelated to this PR, it may have made things slightly more clear if we separate the "base" leaf types from the facts layout db types (who happen to be the same), but not worth it IMO.
crates/starknet_patricia_storage/src/db_object.rs line 52 at r3 (raw file):
Previously, yoavGrs wrote…
Define a constant
NoDbSeparator = b"".
Done. (different name)
yoavGrs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yoavGrs reviewed 5 files and all commit messages, made 1 comment, and resolved 2 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArielElp).
crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde.rs line 55 at r3 (raw file):
Previously, ArielElp wrote…
I don't follow, we want this method ignored, we have a separate DBObject implementation.
Unrelated to this PR, it may have made things slightly more clear if we separate the "base" leaf types from the facts layout db types (who happen to be the same), but not worth it IMO.
I suggested creating a base leaf.
Anyway, that's not going to happen anytime soon.
dorimedini-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dorimedini-starkware reviewed 12 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArielElp and @yoavGrs).
crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde.rs line 55 at r3 (raw file):
Previously, yoavGrs wrote…
I suggested creating a base leaf.
Anyway, that's not going to happen anytime soon.
index layout wraps leaves, but facts layout uses the "base" leaves?
i.e. index layout wraps fact-y leaves and changes behavior?
a bit confusing, no?
suggestion (not in this PR!):
- the DBObject
get_db_keytrait function definition should include a separator argument - seems like it can have a default implementation after (1), right? no need to impl 3 times here
- separator should be defined per layout (const method? associated const, if such a thing exists?)
crates/starknet_patricia_storage/src/db_object.rs line 52 at r3 (raw file):
Previously, ArielElp wrote…
Done. (different name)
why do you have a specific implementation (implementation that doesn't fit all trait implementors) on the trait itself?
I would remove the default impl here, and reinstate it once the separator is a trait-associated-value (or something equivalent) of DBObject trait
crates/starknet_patricia/src/patricia_merkle_tree/traversal_test.rs line 52 at r5 (raw file):
) -> DbKey { // Dummy key for testing purposes (we only need a key when interacting with storage). DbKey(TEST_PREFIX.to_vec())
no longer equivalent, right? previously the DBKey had an extra ":"
doesn't matter though, better this way
Code quote:
DbKey(TEST_PREFIX.to_vec())crates/starknet_committer/src/db/index_db/types.rs line 184 at r5 (raw file):
let prefix = L::get_static_prefix(key_context); let suffix = self.root_index.0.to_be_bytes(); create_db_key(prefix, &[], &suffix)
- make it explicit
- we may want to change this in the future, so no hard-coded literals
const INDEX_DB_KEY_SEPARATOR: &[u8] = b"";
Suggestion:
create_db_key(prefix, INDEX_DB_KEY_SEPARATOR, &suffix)56f611e to
957557e
Compare
9c7d4a5 to
578fe88
Compare
957557e to
73f2def
Compare
578fe88 to
22e313f
Compare
ArielElp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ArielElp made 3 comments.
Reviewable status: 1 of 12 files reviewed, 3 unresolved discussions (waiting on @dorimedini-starkware, @nimrod-starkware, and @yoavGrs).
crates/starknet_committer/src/db/index_db/types.rs line 184 at r5 (raw file):
Previously, dorimedini-starkware wrote…
- make it explicit
- we may want to change this in the future, so no hard-coded literals
const INDEX_DB_KEY_SEPARATOR: &[u8] = b"";
Done (there's already EMPTY_DB_KEY_SEPARATOR, made it pub)
crates/starknet_committer/src/patricia_merkle_tree/leaf/leaf_serde.rs line 55 at r3 (raw file):
Previously, dorimedini-starkware wrote…
index layout wraps leaves, but facts layout uses the "base" leaves?
i.e. index layout wraps fact-y leaves and changes behavior?
a bit confusing, no?
suggestion (not in this PR!):
- the DBObject
get_db_keytrait function definition should include a separator argument- seems like it can have a default implementation after (1), right? no need to impl 3 times here
- separator should be defined per layout (const method? associated const, if such a thing exists?)
Agree on it being a bit confusing. We can have separate wrappers at the end of the stack, though it's unrelated to the question ATM.
Re 1-3, an associated const on DBObject itself seems like the way to go. DBObject impl is clearly layout-dependent, and that way we don't worry about propogating it from e.g. Layout all the way to create_db_key.
TLDR of the changes now:
- Still two arguments
- We do have a default impl now that fits everyone
- Associated const on DBObject
crates/starknet_patricia_storage/src/db_object.rs line 52 at r3 (raw file):
Previously, dorimedini-starkware wrote…
why do you have a specific implementation (implementation that doesn't fit all trait implementors) on the trait itself?
I would remove the default impl here, and reinstate it once the separator is a trait-associated-value (or something equivalent) ofDBObjecttrait
Irrelevant given the discussion above.
dorimedini-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dorimedini-starkware reviewed 11 files and all commit messages, made 1 comment, and resolved 3 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
crates/starknet_committer/src/db/index_db/types.rs line 187 at r6 (raw file):
let prefix = L::get_static_prefix(key_context); let suffix = self.root_index.0.to_be_bytes(); create_db_key(prefix, INDEX_LAYOUT_DB_KEY_SEPARATOR, &suffix)
maybe this is better... separator should really be part of DBObjects only, WDYT?
Suggestion:
IndexFilledNode::<L>::DB_KEY_SEPARATOR22e313f to
af82457
Compare
73f2def to
93bad1e
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dorimedini-starkware reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
af82457 to
7d1c88f
Compare
93bad1e to
7427ed8
Compare
7d1c88f to
fe78bbd
Compare
7427ed8 to
67c930b
Compare
67c930b to
e25225d
Compare
fe78bbd to
cd38a3a
Compare
e25225d to
2f9e569
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dorimedini-starkware reviewed 2 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
2f9e569 to
4e2cfa8
Compare
dorimedini-starkware
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dorimedini-starkware reviewed 2 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ArielElp).
No description provided.